/*
    该文件专门用于暴露一个store对象，整个应用只有一个store对象
*/
// 引用createStore创建redux最为核心的store对象
import { createStore, applyMiddleware, combineReducers } from 'redux'
// 引用处理函数
import headerVisibleReducer from './reducers/headerVisible'
import searchKeywordReducer from './reducers/searchKeyword'
import pageErrorReducer from './reducers/pageError'
// 引用支持异步action的框架 并调用中间件接口装载异步action applyMiddleware(thunk)
import thunk from 'redux-thunk'
// 引用redux-devtools-extension （先在浏览器里安装redux-devtools扩展，还需要在这里配置才生效）
import { composeWithDevTools } from 'redux-devtools-extension'

// 合并多个状态
const allReducer = combineReducers({
    headerVisible: headerVisibleReducer,
    searchKeyword: searchKeywordReducer,
    pageError: pageErrorReducer
})

export default createStore(allReducer, composeWithDevTools(applyMiddleware(thunk)))